package cn.italkcloud.cph.config.thread;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * @author dominate
 * @since 2024/10/7
 **/
@Configuration
@EnableScheduling
@EnableAsync
public class ScheduledThreadConfig {

    private static final int TASK_POOL_SIZE = 5;

    @Bean
    public TaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        taskScheduler.setPoolSize(TASK_POOL_SIZE);
        return taskScheduler;
    }

}
